package com.kymatrix.kycarbon.xsmd.common.business.common;

import cn.hutool.core.convert.Convert;
import java.util.Arrays;
import java.util.Optional;

/**
 * 业务枚举基类
 */
public interface BaseBusinessEnum {
    
    class SysConfigGroupName {

        private SysConfigGroupName(){

        }

        public static final String MODULE_TYPE = "ModuleType";
        public static final String ENABLE_TYPE = "EnableType";
        public static final String BPM_MODEL_FORM_TYPE = "bpm_model_form_type";
        public static final String SUSPENSION_STATE = "SuspensionState";
        public static final String YES_NO = "yes_no";
        public static final String WF_COUNTERSIGN_TYPE = "wf_countersign_type";
        public static final String WF_PROCESS_DEFINE_STATE = "wf_process_define_state";
        public static final String WF_PROCESS_EVENT_TYPE_ENUM = "wf_process_event_type_enum";
        public static final String WF_PROCESS_INSTANCE_STATE = "wf_process_instance_state";
        public static final String WF_PROCESS_SUBMIT_TYPE = "wf_process_submit_type";
        public static final String WF_PROCESS_TASK_PERFORM_TYPE = "wf_process_task_perform_type";
        public static final String WF_PROCESS_TASK_STATE = "wf_process_task_state";
        public static final String WF_PROCESS_TASK_TYPE = "wf_process_task_type";
        public static final String BPM_PROCESS_INSTANCE_STATUS = "BpmProcessInstanceStatus";

        public static final String BPM_TASK_SIGN_TYPE = "BpmTaskSignType";
        public static final String BPM_PROCESS_DEFINE_TYPE = "BpmProcessDefineType";
        public static final String BPM_EXECUTE_TASK_TYPE = "BpmExecuteTaskType";
        public static final String INVERTER_STATUS_TYPE = "InverterStatusType";
        public static final String COLLECT_RESULT_TYPE = "CollectResultType";
        public static final String ALERT_RECORD_STATUS_TYPE = "alertRecordStatusType";
        public static final String ALERT_RECORDTYPE = "AlertRecordType";
        public static final String POWER_STATION_TYPE = "PowerStationType";
        public static final String GRID_CONNECTED_TYPE = "gridConnectedType";
        public static final String PRICE_TYPE = "PriceType";
        public static final String ALERT_NOTIFY_STATUS_TYPE = "alertNotifyStatusType";
    }
    
    
    String getSysConfigGroupName();

    static <E extends Enum<?> & BaseBusinessEnum> Optional<E> codeOf(Class<E> enumClass, Object code) {
        try {
            return Arrays.stream(enumClass.getEnumConstants()).filter(e ->
                    e.getCode().equals(code)
                            || e.name().equalsIgnoreCase(Convert.toStr(code))
            ).findAny();
        } catch (Exception e) {
            return null;
        }
    }


    String getCode();

    String getName();

}
